package socket;

import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * User: heihaier@xfuweng.com
 * Date: 2015/7/7
 * Time: 18:23
 */
public class Server {

    public static void main(String[] args) {

        try {
            ServerSocket server = new ServerSocket(3001);

            while (true) {

                Socket s = server.accept();
                PrintStream ps = new PrintStream(s.getOutputStream());
                for (int i = 0; i < 10; i++) {

                    ps.println("hello, the server socket accept the client ping");
                }
                ps.close();
                s.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
